package org.baojie.raft.node.type;

import org.baojie.raft.node.NodeName;
import org.baojie.raft.store.NodeStore;

public interface Role {

    Name type();

    int getTerm();

    void setTerm(int term);

    void addTerm(int adder);

    NodeStore store();

    default NodeName votedFor() {
        return null;
    }

    default NodeName leader() {
        return null;
    }

    default int votedCount() {
        return 0;
    }

    enum Name {

        FOLLOWER("follower"),
        CANDIDATE("candidate"),
        LEADER("leader");

        private final String name;

        Name(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        @Override
        public String toString() {
            return "RoleName{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }

}
